﻿#region Namespaces

using System;
using System.Text;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using Vibstudio.X4NET.IO.INI;
using Vibstudio.X4NET.IO.INI.Model;
using Vibstudio.X4NET.IO.Path;
using Vibstudio.X4NET.Test.Util;

#endregion

namespace Vibstudio.X4NET.Test
{
    [TestClass]
    public class FileIniDataParserTests
    {
        private const string FILE_NAME = "SampleINI.ini";
        private const string EXPECTED_STRING = "Il file non è nel formato {0}";

        private readonly FilePath _filePath = IOHelper.ComposeSampleFilePath(FILE_NAME);

        [TestMethod]
        public void ReadFile()
        {
            //Encoding encoding = Encoding.Default;
            //Encoding encoding = Encoding.Unicode;
            //Encoding encoding = Encoding.ASCII;
            Encoding encoding = Encoding.UTF8;

            try
            {
                IniData ini = new FileIniDataParser().ReadFile(_filePath.Path, encoding);
                string actual = ini.Sections.GetSectionData("ITA").Keys.GetKeyData("FileFormatValidationFailed").Value;
                Assert.AreEqual(EXPECTED_STRING, actual);
            }
            catch (Exception exception)
            {
                Assert.Inconclusive();
            }
        }
    }
}